<template>
    <div class="main-container">
      <el-row :gutter="20">
        <el-col :span="6">
          <div class="tree-box">
            <div class="title">
              <span>{{$t('user.authorizeInfor.titleSysFunction')}}</span>
            </div>
            <div class="tree">
              <el-tree
                :data="moduleList"
                default-expand-all
                node-key="F_ModuleId"
                ref="moduleTree"
                highlight-current
                :props="moduleProps"
              >
              </el-tree>
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="tree-box">
            <div class="title">
              <span>{{$t('user.authorizeInfor.titleBtnAccess')}}</span>
            </div>
            <div class="tree">
              <el-tree
                :data="buttonList"
                default-expand-all
                node-key="F_ModuleId"
                ref="buttonTree"
                highlight-current
                :props="moduleProps"
              >
              </el-tree>
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="tree-box">
            <div class="title">
              <span>{{$t('user.authorizeInfor.titleFieAccess')}}</span>
            </div>
            <div class="tree">
              <el-tree
                :data="columnList"
                default-expand-all
                node-key="F_ModuleId"
                ref="columnTree"
                highlight-current
                :props="moduleProps"
              >
              </el-tree>
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="tree-box">
            <div class="title">
              <span>{{$t('user.authorizeInfor.titleFormAccess')}}</span>
            </div>
            <div class="tree">
              <el-tree
                :data="formList"
                default-expand-all
                node-key="F_ModuleId"
                ref="formTree"
                highlight-current
                :props="moduleProps"
              >
              </el-tree>
            </div>
          </div>
        </el-col>
      </el-row>

    </div>
  </template>
  
  <script>
  import { getAuthorized } from "@/api/organization/index";
  export default {
    name: "AuthorizeInfo",
    props: {
      objectType: {
        type: Number,
      },
      objectId: {
        type: String,
      }
    },
    data() {
      return {
        buttonList: [],
        columnList: [],
        formList: [],
        moduleList: [],
        moduleProps: {
          children: "children",
          label: "F_FullName",
        }
      };
    },
    mounted() {
      this.getModulesAll();
    },
    methods: {
      getModulesAll() {
        getAuthorized().then((res) => {
          this.moduleList = res.data.data.moduleList;
          this.buttonList = res.data.data.buttonList;
          this.formList = res.data.data.formList;
          this.columnList = res.data.data.columnList;
        });
      }
    }
  };
  </script>
  
<style lang="scss" scoped>
  .main-container {
    height: 100%;
    padding: 0 10px;
  }
  
  .tree-box {
    height: 666px;
    border-top: 1px solid #e9e9e9;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    box-sizing: border-box;
  }
  
  .tree-box .title {
    height: 40px;
    padding: 5px 20px;
    font-size: 14px;
    line-height: 30px;
    font-weight: bold;
    background: #fff;
    border: 1px solid #e9e9e9;
    border-top: none;
    border-bottom: none;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    box-sizing: border-box;
  }
  
  .tree-box .tree {
    height: calc(100% - 40px);
    padding: 20px;
    background: #fff;
    border: 1px solid #e9e9e9;
    overflow-y: auto;
    box-sizing: border-box;
  }
  @media screen and (max-width: 1370px) {
  	   .tree-box{
  		height: 420px;
  	   }   
  	} 
  </style>
  